/*
 一些模块
 */
var _ = require('underscore');
_.mixin(require('./Gruntfile/underscore.mixin'));

var Builder = require('./Gruntfile/' + _.get_group_name() + '/main');

module.exports = function(grunt) {
    var builder = new Builder(grunt);

    var initConfig = {
        pkg: grunt.file.readJSON('package.json'),
        version: Date.now(),
        less: builder.generateLessConfig(),
        watch: builder.generateWatchConfig(),
        requirejs: builder.generateRequirejsConfig()
    };
    if (builder.getInitConfig) {
        _.extend(initConfig, builder.getInitConfig());
    }
    grunt.initConfig(initConfig);
    // 加载plugin
    grunt.loadNpmTasks('grunt-contrib-uglify');
    grunt.loadNpmTasks('grunt-contrib-jshint');
    grunt.loadNpmTasks('grunt-contrib-watch');
    grunt.loadNpmTasks('grunt-contrib-connect');
    grunt.loadNpmTasks('grunt-contrib-concat');
    grunt.loadNpmTasks('grunt-contrib-less');
    grunt.loadNpmTasks('grunt-contrib-livereload');
    grunt.loadNpmTasks('grunt-contrib-cssmin');
    grunt.loadNpmTasks('grunt-contrib-coffee');
    grunt.loadNpmTasks('grunt-contrib-requirejs');
    // 注册任务
    grunt.registerTask('default', ['watch']);
};